package br.com.projeto.databases;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateConfiguration {
	
	private static final SessionFactory session = buildSessionFactory();

	private static SessionFactory buildSessionFactory() {
		try {
			Configuration config = new Configuration();
			config.configure("br/com/projeto/databases/hibernate.cfg.xml");
			return config.buildSessionFactory();
		} catch (Throwable e) {
			System.err.println("Erro ao configurar hibernate");
			throw new ExceptionInInitializerError();
		}
	}

	public static SessionFactory getSession() {
		return session;
	}

}
